﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Solution48
{
    public void Rotate(int[][] matrix)
    {
        //转置
        for (int i = 0; i < matrix.Length; i++)
        {
            for (int j = 0; j < i+1; j++)
            {
              int temp = matrix[i][j];
                matrix[i][j]= matrix[j][i];

                matrix[j][i] = temp;



            }
            
        }

        //对称反转
        for (int i = 0; i < matrix.Length; i++)
        {
            for (int j = 0; j < matrix.Length/2; j++)
            {
                int temp = matrix[i][j];

                matrix[i][j] = matrix[i][matrix.Length - j-1];

                matrix[i][matrix.Length-j - 1] = temp;
            }

        }


    }
}

class Program48
{

    static void Main48(string[] args)
    {
        Solution48 solution = new Solution48();
        int[][] matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
         solution.Rotate(matrix);

        for (int i = 0; i < matrix.Length; i++)
        {
            for (int j = 0; j < matrix[i].Length; j++)
            {
                Console.Write(matrix[i][j]+"  ");
            }
            Console.WriteLine();
        }
    }

}